Skip to content

feat(bank): Bank Link wrapper over the native SDKs - #97

Merged
arosasg merged 3 commits into
mainfrom
feat/bank-link-wrapper
Nov 23, 2026
Merged

arosasg merged 3 commits into
mainfrom
feat/bank-link-wrapper

Conversation

@arosasg

@arosasg arosasg commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

React Native apps had no standalone Bank Link entry point.
The first Android adapter was also written against a shape the native API does not expose: types from the wrong package, fields read off the result instead of its wrapped success / exit values, and enum constants (OPENED) where JavaScript expects the contract's wire names (opened).
A declined presentation left the promise unsettled (on iOS, native logs and never answers when it has no view controller), every payload key native sent reached listeners, and link_id was optional although both bridges send it as null before the id is known.

Solution

  • Both bridges expose presentBankLink, resumeBankLink, handleBankLinkReturn and onBankLinkEvent, mapping native result variants and enum wire names on each platform.
  • A listener receives only that event's allowed fields, so tokens and session credentials are dropped; link_id is required and nullable.
  • A declined presentation rejects the call instead of hanging, on both platforms. On iOS the module resolves the presenting view controller (RCTPresentedViewController, main queue) and passes it to native as from:; with none it never calls native and rejects bank_link / "Bank Link presentation was declined.", the error Android uses. Resume does the same, retrying the lookup for up to 5 seconds first because a host resumes at start-up before a window may exist. The native call result is read untyped, so it compiles whether it returns nothing or a discardable Bool, and a false (nothing opened) rejects the same way.
  • The example forwards the launch URL and warm returns to handleBankLinkReturn before resuming; the README unsubscribes in finally.
  • Bank Link stays off in this change: diditNativeSdkVersions.bankLink is false, so CI and consumers compile the stand-in adapter until the native release that ships Bank Link is pinned.

Verification

  • The Bank Link Jest suites pass (80 tests locally, including the new rejected-promise test) and ESLint is clean on src; CI runs the full suite, typecheck and builds.
  • A native-gating regression test fails if the Android adapter stops using the native package, the wire names, the wrapped result variants or the declined-presentation check; each condition was reverted locally to confirm the test catches it. New iOS conditions (presenter resolved, a missing presenter rejects, the rejection code and message equal Android's, from: passed for present and resume) each failed when reverted.
  • This pull request replaces feat(bank): Bank Link wrapper over the native SDKs #96 with the same files (plus the iOS presenter fix, as a second commit), so that the history that lands on main follows this repository's privacy gate. feat(bank): Bank Link wrapper over the native SDKs #96 is closed once this one merges.

Not in this change

  • Switching Bank Link on. That is a follow-up pull request once the native release is published: it pins that release, sets bankLink to true, compiles the enabled Android adapter against it in CI, and adds the connect and renew proof on devices in the example app.
  • Not verified here: no device or Xcode run, and the iOS Swift and Objective-C++ changes are not compiled locally (CI compiles the stand-in while Bank Link is off).
  • Not verified here: the enabled Android adapter has not been compiled, because CI compiles the stand-in while Bank Link is off.

🤖 Generated with Claude Code

Adds presentBankLink, resumeBankLink, handleBankLinkReturn and
onBankLinkEvent on both bridges, mapping the native result variants and
enum wire names on each platform.

A listener receives only the fields its event allows, a declined
presentation rejects the call, and link_id is required and nullable.

Bank Link stays off (diditNativeSdkVersions.bankLink is false) until the
native release that ships it is pinned.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@arosasg

arosasg commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Codex review (codex CLI, account codex-5, model gpt-5.6-sol)


💡 Code review

Reviewed commit: 5381d61

P1 Badge Reject presentations declined by the iOS SDK

ios/DiditSdkBridge.swift:L446-L455 - view

When DiditSdk.shared.presentBankLink declines a presentation (for example because native cannot present it), its Boolean return value is ignored and no result callback follows, so the JavaScript promise remains pending indefinitely on iOS. Capture the return value as Android does and route a declined presentation through the bridge’s rejection callback rather than waiting for onResult.

Verdict: REQUEST CHANGES

…the promise pending

Resolve the presenting view controller on iOS and reject with the code and message Android uses when there is none.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@arosasg

arosasg commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Codex review (codex CLI, account codex-6, model gpt-5.6-sol)


💡 Code review

Reviewed commit: f1b3184

  • Reject presentations declined by the iOS SDK: open

P1 Badge Reject presentations declined by the iOS SDK

ios/DiditSdkBridge.swift:L462-L472 - view

When a presenter exists but presentBankLink returns false because the native SDK declines to open, this code still discards that return value and no result callback follows, leaving the JavaScript promise pending indefinitely. The new guard only handles a missing presenter; capture the native Boolean result and invoke reject with the shared declined code and message when it is false.

Verdict: REQUEST CHANGES

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@arosasg

arosasg commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Codex review (codex CLI, account codex-3, model gpt-5.6-sol)


💡 Code review

Reviewed commit: c7cb9d3

  • Reject presentations declined by the iOS SDK: closed - ios/DiditSdkBridge.swift:L466-L479 now captures the native return value and rejects when it is false.

No additional findings in commit c7cb9d3.

Verdict: APPROVE

@arosasg
arosasg merged commit cc40c1f into main Nov 23, 2026
11 of 12 checks passed
@arosasg
arosasg deleted the feat/bank-link-wrapper branch November 23, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant